package com.tianji.controller;


import com.tianji.domain.dto.ChatDto;
import com.tianji.domain.vo.ChatVo;
import com.tianji.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/chat")
public class ChatController {
    @Autowired
    private ChatService chatService;
    @PostMapping(produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<ChatVo> chat(@RequestBody ChatDto dto) {
        return chatService.getModelReply(dto);
    }
    @PostMapping("/stop")
    public void stopSession(String sessionId) {
        chatService.stopSession(sessionId);
    }
@PostMapping("/text")
    public String text(@RequestBody String question) {
        return chatService.getReplayText(question);
    }
}
